

package com.hazelcast.client.impl.connection;

import com.hazelcast.cluster.Address;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

/**
 * A collection of addresses. It is split in a group of primary
 * addresses (so the ones that should be tried first) and a group
 * of secondary addresses (addresses that should be tried when the
 * primary group of addresses could not be connected to).
 */
public class Addresses {
    private final List<Address> primary = new LinkedList<>();
    private final List<Address> secondary = new LinkedList<>();

    public Addresses() {
    }

    public Addresses(Collection<Address> primary) {
        this.primary.addAll(primary);
    }

    public void addAll(Addresses addresses) {
        primary.addAll(addresses.primary);
        secondary.addAll(addresses.secondary);
    }

    public List<Address> primary() {
        return primary;
    }

    public List<Address> secondary() {
        return secondary;
    }
}
